fix(security): add input validation to CLI to prevent command injection#990
fix(security): add input validation to CLI to prevent command injection#990bryankthompson wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
- Add validateInput() function with strict character allowlist - Sanitize server name, transport type, and URL inputs - Reject inputs containing shell metacharacters - Prevent command injection through CLI arguments 🤖 Generated with [Claude Code](https://claude.com/claude-code)
8f408e0 to
a89147e
Compare
|
Thanks for thinking about security! After reviewing this with the MCP security guidelines, a few notes: Per the MCP security policy, "STDIO transport command execution to launch servers is intentional design." Since Inspector is a CLI tool where the user directly provides the command to execute, this is working as intended rather than a command injection vulnerability (which would require attacker-controlled input reaching command execution). If you believe there's a specific attack vector where untrusted input could reach command execution, please report it through HackerOne with reproduction steps. Additionally, Inspector V1 is in maintenance mode while V2 is under development, so larger changes like new validation frameworks are being directed to V2. Thanks again for your interest in keeping the project secure! This comment was drafted with assistance from Claude (AI). |
|
Closing per the discussion above. If there's a specific attack vector, please report via HackerOne. |
Summary
Adds input validation to the CLI to prevent potential command injection vulnerabilities.
Changes
isValidEnvVarName()- validates env var names match[a-zA-Z_][a-zA-Z0-9_]*isValidEnvVarValue()- rejects values containing null bytesvalidateEnvVars()- filters invalid env vars with warningsvalidateServerUrl()- validates URL protocol, warns on private IPsvalidateCommand()- checks for shell metacharacters, verifies command existsrunWebClient()andrunCli()functionsSecurity Impact
Test plan
npm run build)🤖 Generated with Claude Code